package com.xzy.sms.web.system.bean;

import java.io.Serializable;
import java.util.List;

import com.google.common.collect.Lists;

/**
 * 组织缓存对象
 * @author macong
 * @since 1.0
 * @version 2014-11-07 macong
 */
public class OrgNodeBean implements Serializable {
    
    /** 序列化 */
    private static final long serialVersionUID = 1L;
    
    /** 组织Id */
    private String orgId;
    
    /** name */
    private String name;
    
    /** 父Id */
    private String parentId;
    
    /** parentIds */
    private String parentIds;
    
    /** fullName */
    private String fullName;
    
    /** sort */
    private int sort;
    
    /** 层级 */
    private int level;
    
    /** 包含用户id */
    private List<String> userIds;
    
    /** 子节点 */
    private List<OrgNodeBean> child;
    
    /**
     * 构造函数
     */
    public OrgNodeBean() {
    }
    
    /**
     * 构造函数
     * 
     * @param orgId orgId
     * @param parentId parentId
     */
    public OrgNodeBean(String orgId, String parentId) {
        super();
        this.orgId = orgId;
        this.parentId = parentId;
    }
    
    /**
     * 构造函数
     * 
     * @param orgId orgId
     * @param name name
     * @param parentId parentId
     * @param parentIds parentIds
     * @param fullName fullName
     * @param sort sort
     */
    public OrgNodeBean(String orgId, String name, String parentId, String parentIds, String fullName, int sort) {
        this.orgId = orgId;
        this.name = name;
        this.parentId = parentId;
        this.parentIds = parentIds;
        this.fullName = fullName;
        this.sort = sort;
    }
    
    /**
     * 添加userId
     * 
     * @param userId userId
     */
    public void addUserId(String userId) {
        if (null == this.userIds) {
            this.userIds = Lists.newArrayList();
        }
        this.userIds.add(userId);
    }
    
    /**
     * 删除userId
     * 
     * @param userId userId
     */
    public void removeUserId(String userId) {
        if (null != userId && null != this.userIds) {
            this.userIds.remove(userId);
        }
    }
    
    /**
     * 添加子节点
     * 
     * @param orgNodeBean orgNodeBean
     */
    public void addChild(OrgNodeBean orgNodeBean) {
        if (null == orgNodeBean) {
            return;
        }
        if (null == this.child) {
            this.child = Lists.newArrayList();
        }
        this.child.add(orgNodeBean);
    }
    
    /**
     * 删除子节点
     * 
     * @param orgNodeBean orgNodeBean
     */
    public void removeChild(OrgNodeBean orgNodeBean) {
        if (null != orgNodeBean && null != this.child) {
            this.child.remove(orgNodeBean);
        }
    }
    
    /**
     * @return userIds
     */
    public List<String> getUserIds() {
        return userIds;
    }
    
    /**
     * @param userIds 要设置的 userIds
     */
    public void setUserIds(List<String> userIds) {
        this.userIds = userIds;
    }
    
    /**
     * @return orgId
     */
    public String getOrgId() {
        return orgId;
    }
    
    /**
     * @param orgId 要设置的 orgId
     */
    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }
    
    /**
     * @return child
     */
    public List<OrgNodeBean> getChild() {
        return child;
    }
    
    /**
     * @param child 要设置的 child
     */
    public void setChild(List<OrgNodeBean> child) {
        this.child = child;
    }
    
    /**
     * @return parentId
     */
    public String getParentId() {
        return parentId;
    }
    
    /**
     * @param parentId 要设置的 parentId
     */
    public void setParentId(String parentId) {
        this.parentId = parentId;
    }
    
    /**
     * @return level
     */
    public int getLevel() {
        return level;
    }
    
    /**
     * @param level 要设置的 level
     */
    public void setLevel(int level) {
        this.level = level;
    }
    
    /**
     * @return name
     */
    public String getName() {
        return name;
    }
    
    /**
     * @param name 要设置的 name
     */
    public void setName(String name) {
        this.name = name;
    }
    
    /**
     * @return parentIds
     */
    public String getParentIds() {
        return parentIds;
    }
    
    /**
     * @param parentIds 要设置的 parentIds
     */
    public void setParentIds(String parentIds) {
        this.parentIds = parentIds;
    }
    
    /**
     * @return fullName
     */
    public String getFullName() {
        return fullName;
    }
    
    /**
     * @param fullName 要设置的 fullName
     */
    public void setFullName(String fullName) {
        this.fullName = fullName;
    }
    
    /**
     * @return sort
     */
    public int getSort() {
        return sort;
    }
    
    /**
     * @param sort 要设置的 sort
     */
    public void setSort(int sort) {
        this.sort = sort;
    }
    
    /**
     * @return xx
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((orgId == null) ? 0 : orgId.hashCode());
        return result;
    }
    
    /**
     * @param obj obj
     * @return xx
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        OrgNodeBean other = (OrgNodeBean) obj;
        if (orgId == null) {
            if (other.orgId != null)
                return false;
        } else if (!orgId.equals(other.orgId))
            return false;
        return true;
    }
}
